const behavior = require('../models/behavior')

module.exports.logBehavior = () => {
	return (ctx, next) => {
		const date = Date.now()
		const body = ctx.request.body
		const query = ctx.request.query
		const finger = body.finger || query.finger
		const url = ctx.url
		behavior.save({
			uid: finger,
			path: url,
			content: query || body,
			createTime: date
		})
	}
}